# -*- coding: utf-8 -*-

#   This file is part of emesene.
#
#    Shortcut plugin is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    Shortcut plugin is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with emesene; if not, write to the Free Software
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

VERSION = '0.1'

import gtk
import emesenelib.common
import Plugin

class MainClass(Plugin.Plugin):
    '''Main plugin class'''

    description = _('Toolbar to host some cool buttons')
    authors = {'Orfeo Ciano':'orfeo18@gmail.com'}
    website = ''
    displayName = _('Toolbar')
    name = 'Toolbar'
    def __init__(self, controller, msn):
        '''Contructor'''

        Plugin.Plugin.__init__(self, controller, msn )

        self.description = _('Toolbar to host some cool buttons')
        self.authors = {'Orfeo Ciano':'orfeo18@gmail.com'}
        self.website = ''
        self.displayName = _('Toolbar')
        self.name = 'Toolbar'
        self.controller = controller
        self.core = msn

    def start(self):
        #Get all button widgets present in lateral bar
        buttChildren = self.controller.mainWindow.userPanel.vbox2.get_children()
        
        #delete all button widgets presents in lateral bar
        for i in buttChildren:
            self.controller.mainWindow.userPanel.vbox2.remove(i)
        
        #Change Vertical orientation to Horizontal orientation
        self.controller.mainWindow.userPanel.vbox2 = gtk.HBox()
        
        #add all button widgets present in lateral bar
        for i in buttChildren:
            self.controller.mainWindow.userPanel.vbox2.pack_start(i,False,False)
        
        #add new box to interface
        self.controller.mainWindow.userPanel.vbox1.pack_start(self.controller.mainWindow.userPanel.vbox2,True,True)
        #show all widgets
        self.controller.mainWindow.userPanel.vbox2.show_all()
        
        #Done!
        self.enabled = True

    def stop(self):
        #Get all button widgets present in toolbar
        buttChildren = self.controller.mainWindow.userPanel.vbox2.get_children()
        
        #delete all button widgets presents toolbar
        for i in buttChildren:
            self.controller.mainWindow.userPanel.vbox2.remove(i)
        
        #Change Horizontal orientation to Vertical orientation
        self.controller.mainWindow.userPanel.vbox2 = gtk.VBox()
        
        #add all button widgets present in toolbar
        for i in buttChildren:
            self.controller.mainWindow.userPanel.vbox2.pack_start(i,True,False)
        
        #add new box to interface
        self.controller.mainWindow.userPanel.hbox.pack_start(self.controller.mainWindow.userPanel.vbox2,False,False)
        #show all widgets
        self.controller.mainWindow.userPanel.vbox2.show_all()
        self.enabled = False

    def check(self):
        return (True, 'Ok')
